package com.dpl.yyrj.ui.imageChoose;

import java.util.ArrayList;
import java.util.List;

/**
 * 相册类
 * */
public class AlbumList {
	
	public List<Album> albumList;
	private Album all;
//	private BaseAdapter adapter;
	private int N = 100;

	public AlbumList(){
		albumList = new ArrayList<Album>();
		all = new Album();
		all.setName("最近照片");//100張圖片
		all.setBuckId(-12306);//添加id
		albumList.add(all);
//		this.adapter = adapter;
//		adapter.notifyDataSetChanged();
	}
	/**添加相册中的图片到list中
	 * */
	public void addIamge(String photoPath,String albumName,long datatime,long albumId){
		Album album = getAlbumById(albumList, albumId);
		if (album == null) {
			album = new Album();
			album.setBuckId(albumId);
			album.setName(albumName);
			albumList.add(album);
//			adapter.notifyDataSetChanged();
		}
		album.addPhoto(photoPath);
		if (all.getSize() < N) {//最多N张图片
			all.addPhoto(photoPath);
		}
	}
	
	private Album getAlbumById(List<Album> list,long id){
        for (Album album : list) {
            if(album.getBuckId()==id){
                return album;
            }
        }
        return null;
	}
	
}
